(translator=pacific, ChineseSource=pacific-20020619-10\open.html, EnglishSource=c:\matlabr12\help\techdoc\ref\open.html)
MATLAB Function Reference    
open

根據延伸檔名來開啓檔案。

Syntax

Description

open('name') 開啓檔案 name 並根據 name 的檔案種類來決定其開檔方式。

name
Action
變數
用陣列編輯器(Array Editor)來開啓陣列 name (陣列一定為數字)(the array must be numeric); open 會呼叫 openvar
figure檔案 (*.fig)
用 figure window來開啓圖形(figure)
HTML檔案 (*.html)
用求助瀏覽器(Help browser)來開啓HTML文件。
M檔案 (name.m)
用M檔案編輯器(M-file Editor)來開啓M檔案。
模型(model) (name.mdl)
用Simulink來開啓模型(model) name 。
p檔案 (name.p)
若對應的M檔案 name.m 存在,會用編輯器來開啓它。
其他檔案 (name.custom)
呼叫 opencustom 來開啓 name.custom ,其中 opencustom 是使用者自己定義的函式。

Remarks

Behavior When name Does Not Have an Extension

若 name 沒有延伸檔名, open 會去開啓 which(name)所回傳的物件,其中 name 是變數、函式或模型(model)。若找不到適合的函式來開啓檔案,會用預設的編輯器去開啓。

下面這一段不太確定 ->

若 name 中沒有包含延伸檔名,但也有一個檔案也沒有延伸檔名且檔案名稱和 name 相同, open 會用編輯器來開啓它。若找不到沒有延伸檔名且檔案名稱和 name 相同的檔案, open 會去找同路徑同檔名的M檔案,若找到這樣的檔案,就會開啓它。(If name does not contain a file extension and there is a matching filename without an extension, open opens the file in the editor. If it does not find a matching file without an extension, open looks for an M-file with the same name on the path, and if found, opens it in the editor.)

若 name 是變數, open 會呼叫 openvar。

Create Custom open

使用者可以利用自己定義的 opencustom 來修改對已知種類的檔案的預設處理方式或設定對新種類的檔案的處理方式。 open 會呼叫其在路徑中所找到的 opencustom 函式。

Examples

Example 1 - No File Extension Specified

若 testdata 在路徑中

利用編輯器來開啓 testdata 。

若找不到 testdata ,但在路徑中找到 testdata.m

利用編輯器來開啓 testdata.m 。

Example 2 - No File Extension Specified, M-file and Model Files Present

若 testdata.m 和 testdata.mdl 都在路徑中,輸入:

testdata.mdl 會用 Simulink 來開啓testdata.mdl 。因為模型優先於(take precedence over) M檔案,你可以輸入下列指令來檢視:

回傳優先執行檔案(It returns the file that takes precedence),在這個例子中:

Example 3 - Customized open

open('mychart.cht') 呼叫 opencht('myfigure.cht')。其中 opencht 是使用者在.cht 檔案中定義的函式。

See Also

hgload, hgsave, load, openvar, save, saveas


 ones openfig